package org.liao.springboot.webservice.ws.client;


import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;

public class JaxWsProxyFactoryBeanClient {
    public static void main(String[] args) {
        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
        factory.setServiceClass(WeatherInterClientFace.class);
        factory.setAddress("http://localhost:1899/weather");
        WeatherInterClientFace client = (WeatherInterClientFace) factory.create();
        ClientProxy.getClient(client).getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
        ClientProxy.getClient(client).getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
        WeatherInfoClientReq weatherInfoReq=new WeatherInfoClientReq();
        weatherInfoReq.setCity("三门峡");
        weatherInfoReq.setSendTime(System.currentTimeMillis());
        WeatherInfoClientResp resp = client.getWeatherByCity(weatherInfoReq);
        System.out.println("Server said: " + resp);
    }
}
